import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 测试java语言的性能
 * @author fjl
 *
 */
public class JavaTest
{

	public static void main(String[] args)
	{
		sub();
		
//		percentTest();
	}
	
	
	
	/**
	 * 百分比测试
	 */
	
	public static void percentTest()
	{
		 int diliverNum=3;//举例子的变量
         int queryMailNum=9;//举例子的变量
         
  		
         // 创建一个数值格式化对象   
        NumberFormat numberFormat = NumberFormat.getInstance();   
         // 设置精确到小数点后2位   
         numberFormat.setMaximumFractionDigits(2);   
        String result = numberFormat.format((float)diliverNum/(float)queryMailNum*100);
        System.out.println("diliverNum和queryMailNum的百分比为:" + result + "%");      	    

        //测试代码留作纪念
        double percent = (float)diliverNum/(float)queryMailNum*100;
 		System.out.println(percent);
 		 double percentTest = diliverNum/queryMailNum*100;
  		System.out.println("见证奇迹的时候："+percentTest);
	}
	
	
	
	/**
	 * 累加测试
	 * 
	 * @return
	 */
	public static double sub()
	{
		 long startTime=System.currentTimeMillis();
		int sum = 0;
	  for(int i = 0; i < 10000000; i++ )
	  {
		  
		  sum += i; 
	  }
	  long endTime=System.currentTimeMillis();
	  //计算时间差
	  long number = startTime - endTime;
//	  System.out.println(number);
	  float excTime=(float)(endTime-startTime)/1000;
      System.out.println("执行时间："+excTime+"s");
	  
	  return sum;
	}
}
